package com.cy.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

//借助此对象在业务层封装业务逻辑结果
@Data
@NoArgsConstructor
public class PageObject<T> implements Serializable {
    private static final long serialVersionUID = -6010170587490380722L;//类名<泛型>===>类泛型--->约束类中属性，方法参数以及返回值类型
    /**当前页的页码值*/
    private Integer pageCurrent;
    /**总行数(通过查询获得)*/
    private Integer rowCount;
    /**当前页记录*/
    private List<T> records;
    /**总页数(通过计算获得)*/
    private Integer pageCount;
    /**页面大小*/
    private  Integer pageSize;

    public PageObject(Integer pageCurrent, Integer rowCount, List<T> records, Integer pageSize) {
        this.pageCurrent = pageCurrent;
        this.rowCount = rowCount;
        this.records = records;
        this.pageSize = pageSize;
        this.pageCount=rowCount/pageSize;
		if(this.rowCount%this.pageSize!=0){
		    this.pageCount++;
		}
		//this.pageCount=(rowCount-1)/pageSize+1;
    }
}
